package xc.com.course.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {
    /**
     * 是否开启swagger，正式环境一般是需要关闭的，可根据springboot的多环境配置进行设置
     * @return
     */
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("xc.com.course.controller"))
                .paths(PathSelectors.any()).build();
    }
    /**
     * swagger-ui页面信息
     * @return
     */
    public ApiInfo apiInfo(){
        return  new ApiInfoBuilder()
                .title("在线教育平台")
                .description("api接口文档")
                .version("2.2.2")
                .build();
//        return new ApiInfo("","","","","","","");
    }

    }

